package org.android.tools;

import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

public class Shop implements KvmSerializable {

	public Integer idshop;
	public String name;
	public String street;
	public int number;
	public String city;
	public String country;
	public Double x;
	public Double y;
	
	public Shop() {}
	
    public Shop(String name, String street, int number, String city, String country) {
        this.name = name;
        this.street = street;
        this.number = number;
        this.city = city;
        this.country = country;
    }
    
    public Shop(String name, String street, int number, String city, String country, Double x, Double y) {
       this.name = name;
       this.street = street;
       this.number = number;
       this.city = city;
       this.country = country;
       this.x = x;
       this.y = y;
    }
    
	
	public Object getProperty(int arg0) {
		// TODO Auto-generated method stub
		switch(arg0)
        {
        case 0:
        	return city;
        case 1:
        	return country;
        case 2:
            return idshop;
        case 3:
            return name;
        case 4:
        	return number;
        case 5:
        	return street;
        case 6:
        	return x;
        case 7:
        	return y;
        }
		return null;
	}

	public int getPropertyCount() {
		// TODO Auto-generated method stub
		return 8;
	}

	public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
		// TODO Auto-generated method stub
		switch(arg0)
        {
        case 0:
        	arg2.type = PropertyInfo.STRING_CLASS;
        	arg2.name = "city";
        	break;
        case 1:
        	arg2.type = PropertyInfo.STRING_CLASS;
        	arg2.name = "country";
            break;
        case 2:
            arg2.type = PropertyInfo.INTEGER_CLASS;
            arg2.name = "idshop";
            break;
        case 3:
        	arg2.type = PropertyInfo.STRING_CLASS;
        	arg2.name = "name";
            break;
        case 4:
        	arg2.type = PropertyInfo.INTEGER_CLASS;
        	arg2.name = "number";
            break;
        case 5:
        	arg2.type = PropertyInfo.STRING_CLASS;
        	arg2.name = "street";
        	break;
        case 6:
        	arg2.type = Double.class;
        	arg2.name = "x";
        	break;
        case 7:
        	arg2.type = Double.class;
        	arg2.name = "y";
        	break;
        default:break;
        }
	}

	public void setProperty(int arg0, Object arg1) {
		// TODO Auto-generated method stub
		switch(arg0)
        {
        case 0:
            city = arg1.toString();
            break;
        case 1:
            country = arg1.toString();
            break;
        case 2:
            idshop = Integer.parseInt(arg1.toString());
            break;
        case 3:
            name = arg1.toString();
            break;
        case 4:
            number = Integer.parseInt(arg1.toString());
            break;
        case 5:
            street = arg1.toString();
            break;
        case 6:
            x = Double.parseDouble(arg1.toString());
            break;
        case 7:
            y = Double.parseDouble(arg1.toString());
            break;
        default:
            break;
        }
	}
	
	public static Shop parseShop(SoapObject soap, int arg0)
	{
		SoapObject pii = (SoapObject) soap.getProperty(arg0);
		Shop shop = new Shop();
        shop.city = pii.getProperty(0).toString();
        shop.country = pii.getProperty(1).toString();
        shop.idshop = Integer.parseInt(pii.getProperty(2).toString());
        shop.name = pii.getProperty(3).toString();
        shop.number = Integer.parseInt(pii.getProperty(4).toString());
        shop.street = pii.getProperty(5).toString();
        shop.x = Double.parseDouble(pii.getProperty(6).toString());
        shop.y = Double.parseDouble(pii.getProperty(7).toString());
        return shop;
	}
	
	public static Shop[] parseShop(SoapObject soap)
    {
        Shop[] shops = new Shop[soap.getPropertyCount()];
        for (int i = 0; i < shops.length; i++) {
            SoapObject pii = (SoapObject)soap.getProperty(i);
            Shop shop = new Shop();
            shop.city = pii.getProperty(0).toString();
            shop.country = pii.getProperty(1).toString();
            shop.idshop = Integer.parseInt(pii.getProperty(2).toString());
            shop.name = pii.getProperty(3).toString();
            shop.number = Integer.parseInt(pii.getProperty(4).toString());
            shop.street = pii.getProperty(5).toString();
            shop.x = Double.parseDouble(pii.getProperty(6).toString());
            shop.y = Double.parseDouble(pii.getProperty(7).toString());
            shops[i] = shop;
        }
        return shops;
    }
}
